package com.akk.utils;

import com.alibaba.fastjson.JSON;
import org.apache.commons.lang.StringEscapeUtils;
import org.springframework.util.StringUtils;

import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * 查询参数
 *

 */
public class Query implements Serializable {
	private static final long serialVersionUID = 1L;
	//当前页码
    @NotNull(message = "当前页码不能为空")
    private int page;
    //每页条数
    @NotNull(message = "每页显示条数不能为空")
    private int limit;

    private String searchStr;

    private Map search;



    public int getPage() {
        return page;
    }

    public void setPage(int page) {
        this.page = page;
    }

    public int getLimit() {
        return limit;
    }

    public void setLimit(int limit) {
        this.limit = limit;
    }

    public String getSearchStr() {
        return searchStr;
    }

    public void setSearchStr(String searchStr) {
        this.searchStr = StringUtils.isEmpty(searchStr) ? "" : StringEscapeUtils.unescapeHtml(searchStr);
    }

    public Map getSearch() {
        return StringUtils.isEmpty(this.getSearchStr()) ? new HashMap() : (Map) JSON.parse(this.searchStr);
    }

    public void setSearch(Map search) {
        this.search = search;
    }
}
